#include "interpreter.h"

model::interpreter::interpreter(const model::dom &node)
{
	parse(node);
}

void model::interpreter::parse(const model::dom &node)
{
	_name = node.find_attrib("name");
	boost::shared_ptr<model::dom> ptr(
		node.find("album"));
	while(*ptr) {
		_albums.push_back(model::album(*ptr));
		ptr = ptr->next_tag();
	}
}

void model::interpreter::print() const
{
	cout << "Interpreter: " << _name << endl;
	for(list<model::album>::const_iterator i = _albums.begin(); 
	    i != _albums.end(); ++i) {
		i->print();
	}
}

string model::interpreter::to_xml() const
{
	string tmp = "<interpreter name=\"" + _name + "\">";
	typedef list<model::album>::const_iterator it;
	for(it i = _albums.begin(); i != _albums.end(); ++i) {
		tmp += i->to_xml();
	}
	tmp += "</interpreter>";
	return tmp;
}

